package org.hyl.javabase.反射;

import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.text.SimpleDateFormat;
import java.util.Date;

public class student implements Serializable,Subject
{
	/**
	 * 
	 */

	private static final long serialVersionUID = 1L;
	String name="";
	String addr="";
	public String idc="";
	private String pp="";
	public student(){		
		name="xiao hong";
	}

	public student(String name){
		this.name=	name;
	}
	public student(String name,String addr) throws Exception{
		this.name=	name;
		this.addr=	addr;
	}
	
	public String getName(){
		System.out.println("print getName");
		return this.name;
	}
	public void setName(String name){
		System.out.println("print setName");
		this.name=name;
	}
	public static String getNow(){
		Date now = new Date();
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式
		String hehe = dateFormat.format( now ); 
		return hehe;
	}
	public static String getInt(int a){
		return "int a="+a;
	}
	public static String getInteger(Integer a){
		return "Integer a="+a.intValue();
	}
	public String toString(){
		return name;
	}
	@Override
	public String say(String name, int age) {
		// TODO Auto-generated method stub
		  return name + " 的 年龄= " + age;
	}
	
}
interface Subject {
    public String say(String name, int age);
}
class MyInvocationHandler implements InvocationHandler {
    private Object obj = null;
    public Object bind(Object obj) {
        this.obj = obj;
        return Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), this);
    }
	@Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        Object temp = method.invoke(this.obj, args);
        return temp;
    }
}
